<?php
session_start();
include 'fungsi.php';
$baru = new fungsi();
$baru->konek();
$nama = $_POST['username'];
$pass = $_POST['password'];
$log=$_GET['log'];

if($log=="in"){ 
	$sql=mysql_query('select * from profil_akun  where nama="'.$nama.'" and password=md5("'.$pass.'")');
	if(mysql_num_rows($sql)>0){
	        $masuk= mysql_fetch_array($sql);
			
	        $_SESSION['username']= $masuk['nama'];
	//		$cek = $_SESSION['usename'];
//			echo $cek;
	        $_SESSION['hak_akses'] = $masuk['hak_akses']; 
	        if($masuk['hak_akses']=="1"){ 
	            header("location:home_adm.php?"); 
	        }else if($masuk['hak_akses']=="2"){ 
	            header("location:form-daftar-akun.php"); 
				} else if($masuk['hak_akses']=="3"){
						header("location:home-pembeli.php"); 
					}
	    }else{ 
		?>
	         <script>alert('username dan password anda salah !');</script>
<?php
			$page = "home-guess.php";
			$keluar = $baru->redirectPage($page);
			echo $keluar;
			 } 
	}else if($log=="out"){ 
	    unset($_SESSION['username']); 
	    unset($_SESSION['hak_akses']); 
	    header("location:home-guess.php"); 
	} 
?> 
